package com.example.smart.dialog

import android.app.Activity
import android.content.Context
import android.view.Gravity
import android.view.View
import com.example.lib.extend.getDeviceWidth
import com.example.lib.extend.setOnDoubleClickListener
import com.example.lib.utils.AppUtils
import com.example.smart.R
import com.example.smart.base.dialog.base.BaseDialog
import com.example.smart.databinding.DialogSexBinding

class SexDialog(val activity: Activity) : BaseDialog<DialogSexBinding>(dialogContext = activity,
    width = (getDeviceWidth(activity) * 0.95).toInt(),
    gravity = Gravity.BOTTOM) {

    var onResult: ((String) -> Unit)? = null

    override fun setLayoutRes() = R.layout.dialog_sex

    override fun afterViewCreate(view: View?) {
        val data = mutableListOf(context.getString(R.string.sex_g), context.getString(R.string.sex_m))

        binding.DialogWheel1.data = data

        binding.DialogClose.setOnDoubleClickListener {
            dismiss()
        }

        binding.DialogConfirm.setOnDoubleClickListener {
            dismiss()
            onResult?.invoke(data[binding.DialogWheel1.currentPosition])
        }
    }

    override fun show() {
        AppUtils.packUpInputKey(activity = activity)
        super.show()
    }


}